from django.shortcuts import render
from . import serializers
from .models import CourseCategory, Course
from rest_framework.generics import ListAPIView
from django_filters.rest_framework import DjangoFilterBackend
from rest_framework.filters import OrderingFilter


# Create your views here.


class CourseCategoryListAPIView(ListAPIView):
    queryset = CourseCategory.objects.filter(is_show=True, is_deleted=False).order_by('orders')
    serializer_class = serializers.CourseCategorySerializer


class CourseListView(ListAPIView):
    queryset = Course.objects.filter(is_deleted=False, is_show=True).order_by('orders')
    serializer_class = serializers.CourseModelSerializer
    filter_backends = [DjangoFilterBackend, OrderingFilter]
    filter_fields = ('course_category',)
    # ordering_fields = ('id', 'students', 'price')
